﻿using System;
using System.Collections.Generic;
using System.Text;
using Torch.WL.Business.Interface;
using Torch.FrameWork.Utility;
using Torch.WL.Business.CleanChina;
using Torch.WL.Entity.CleanChina;

namespace Torch.WL.Business
{
    public class Forum1Provider: BaseProvider<Forum1Provider.RequestDataInfo>, IDataProvider
    {
        public Forum1Provider(string _jsonInfo) : base(_jsonInfo)
        {

        }

        public IMessageInfo Do()
        {
            IMessageInfo message = new MessageInfo();
            message.code = (int)MessageCodeType.Success;
            message.message = Utils.GetEnumDescription(MessageCodeType.Success);
            message.data = ProcessResponseData();

            return message;
            
        }

        private ResponseDataInfo ProcessResponseData()
        {
            //use postdata.data to process responseData            
            ResponseDataInfo responseData = new ResponseDataInfo();

            if (postdata == null || postdata.data == null)
            {
                message.code = (int)MessageCodeType.WrongRequestPara;
                message.message = Utils.GetEnumDescription(MessageCodeType.WrongRequestPara);
                return null;
            }


            TbForumEntity entity = TbForumManager.Instance().GetModelByCache(postdata.data.forum_id);

            if (entity == null)
                return null;

            //forumType tinyint,--1=高峰论坛 2=一般论坛 3=比赛 4=秀

            responseData.forum_id = entity.forumId;
            responseData.forum_name = entity.forumName;
            responseData.type = entity.forumType;
            responseData.forum_date = entity.showDate;
            responseData.forum_address = entity.Place;
            responseData.summary = entity.Memo;
            if (entity.forumType == 1 || entity.forumType == 2)
                responseData.instructor = entity.forumTeacher;
            else
                responseData.instructor = entity.raceZanZhu;

            if (entity.forumType == 1 || entity.forumType == 2)
                responseData.agenda = entity.forumTheme;
            else
                responseData.agenda = entity.racePerson;

            #region 虚代码
            /*
            if (postdata.data.forum_id == 100)
            {
                responseData = new ResponseDataInfo();
                responseData.forum_id = postdata.data.forum_id;
                responseData.name = "高峰论坛";
                responseData.type = 1;
                responseData.date = "2014年3月15日";
                responseData.place = "1号馆";
                responseData.summary = "比较长的文字,并且可能有段落的\n\r 比如像这样的";
                responseData.instructor = "陈汉阳";
                responseData.agenda = "上午的议程、下午的议程";
            }

            if (postdata.data.forum_id == 101)
            {
                responseData = new ResponseDataInfo();
                responseData.forum_id = postdata.data.forum_id;
                responseData.name = "石材养护论坛";
                responseData.type = 2;
                responseData.date = "2014年3月15日";
                responseData.place = "1号馆";
                responseData.summary = "比较长的文字,并且可能有段落的\n\r 比如像这样的";
                responseData.instructor = "讲师:陈汉阳";
                responseData.agenda = "议题:上午的议题、下午的议题";
            }



            if (postdata.data.forum_id == 102)
            {
                responseData = new ResponseDataInfo();
                responseData.forum_id = postdata.data.forum_id;
                responseData.name = "玻璃擦拭比赛";
                responseData.type = 3;
                responseData.date = "2014年3月15日";
                responseData.place = "1号馆";
                responseData.summary = "规则:比较长的文字,并且可能有段落的\n\r 比如像这样的";
                responseData.instructor = "赞助:陈汉阳";
                responseData.agenda = "比赛人员";
            }

            if (postdata.data.forum_id == 103)
            {
                responseData = new ResponseDataInfo();
                responseData.forum_id = postdata.data.forum_id;
                responseData.name = "职业装秀";
                responseData.type = 4;
                responseData.date = "2014年3月15日";
                responseData.place = "1号馆";
                responseData.summary = "比较长的文字,并且可能有段落的\n\r 比如像这样的";
                responseData.instructor = "赞助:陈汉阳";
                responseData.agenda = "比赛人员";
            }
             * */
            #endregion

            return responseData;         
        }

        public class RequestDataInfo 
        {
            public int forum_id { get; set; }
        }

        public class ResponseDataInfo
        {
            /* ""forum_id"":论坛编号,
               ""name"":""论坛名称"",
               ""type"":1(高峰论坛)或2(一般论坛)或3(比赛)或4(秀),
               ""date"":""时间"",
               ""place"":""地点"",
               ""summary"":""简介或规则"",
               ""instructor"":""讲师或赞助"",
               ""agenda"":""议程或议题或人员""
             */
            public int forum_id { get; set; }
            public string forum_name { get; set; }
            public int type { get; set; }
            public string forum_date { get; set; }
            public string forum_address { get; set; }

            public string summary { get; set; }
            public string instructor { get; set; }
            public string agenda { get; set; }

        }


    }
}
